<template>
  <el-select v-model="particularYear"
              placeholder="请选择年份"
              @input="handleInput">
    <el-option v-for="item in yearList"
                :key="item.id"
                :label="item.name"
                :value="item.name"/>
  </el-select>
</template>

<script>
export default {
  name: "YearSelect",
  props: {
    value: {
      type: Array
    },
    options: {
      type: [Object, Array],
      default () {
        return { range: "date" };
      }
    },
    label: {
      type: String,
      delete: null
    }
  },
  data () {
    return {
      particularYear: '',
      yearList: [
        { id:0, name: "" },
        { id:1, name: "" }
      ]
    };
  },
  computed: {
    range () {
      return this.options?.range || "date";
    },
    normalizedType () {
      return this.range + "range";
    },
    placeholderName () {
      return RANGE_NAMES[this.range];
    }
  },
  mounted () {
    this.locationInHone();
  },
  methods: {
    locationInHone () {
      let now = new Date();
      let currentYear = now.getFullYear()
      this.yearList[0].name = currentYear;
      this.yearList[1].name = currentYear - 1;
    },
    handleInput (e) {
      this.particularYear = e;
      let value = []
      value = [e]
      this.$emit("input", value);
    }
  }
};
</script>

<style scoped></style>
